public class SavingAccount extends BaseAccount{
    private static double rate; // 年利率


    public SavingAccount(String name, int ID, double balance) {
        super(name, ID, balance);
        SavingAccount.rate = rate; // 初始化年利率
    }

    public static double getRate() {
        return rate;
    }

    public static void setRate(double rate) {
        SavingAccount.rate = rate;
    }
    // 计算月利息
    public double calculateMonthlyInterest() {
        return getBalance() * rate / 12;
    }

    // 重写查询用户账户信息方法
    @Override
    public void printAccountInfo() {
        super.printAccountInfo(); // 调用父类方法
        System.out.println("年利率: " + rate * 100 + "%");
    }
}

